var express = require('express');
var router = express.Router();

const Vue = require('vue')
const renderer = require('vue-server-renderer').createRenderer()

/* GET home page. */
// 同构
router.get('/', function(req, res, next) {
  // console.log(req)
  console.log(res)
  const app = new Vue({
    template: `<div>{{message}}</div>`,
    data: {
      message: 'hello world'
    }
  })
  renderer.renderToString(app, (err, html) => {
    if (err) throw err
    res.send(html)
  })
})

module.exports = router;
